This script is used to convert the program output to json result files (one for each instance). All the program output is stored in the data subfolder

Note set working dir to source file location when you work with the script. ### Setup Install packages:

Get all instances

Read result output

Check if output consistent

Different tests on each instance?

An example:

That is the tests differ in nodesel and varsel. #### Do all results have an instance file?

Create json files

All result files are in csv format with comma delimitor and dot as decimal mark.

for (iName in unique(dat\(instance)) { # 1:nrow(dat) tmp <- dat %>% dplyr::filter(instance == iName) resFilesTmp <- grep(iName, resFiles, value = T) if (length(resFilesTmp) > 0) { message(iName,": ") cat(iName, ": ", sep="") mth1 <- paste0(tmp\)nodesel, “", tmp\(varsel, "_", tolower(tmp\)OB)) if (all(file_exists(paste0("../", iName, "”, mth1, "_result.json“)))) { cat(”Already generated for all methods!“) next } pts0 <- read_csv(grep(str_c(iName,”UB“), resFiles, value = T), col_types = cols())[,1:tmp$p[1]] %>% mutate(rowId = 1:nrow(.)) pts <- addNDSet(pts0[,1:tmp$p[1]]) %>% select(-(nd:us), type =”cls“) pts <- full_join(pts0, pts, by = c(”z1“,”z2“,”z3“)) %>% arrange(rowId) %>% # so the order will be the same as in XE select(contains(”z“), type) # coeff <- read_csv(grep(str_c(iName,”coef“), resFiles, value = T)) # coeffRatio <- sum(coeff\(nondominated)/nrow(coeff) for (i in 1:nrow(tmp)) { message("\n\nFile ", tmp\)rowname[i],”/“, nrow(dat),”“) mth1 <- paste0(tmp\(nodesel[i], "_", tmp\)varsel[i],”“, tolower(tmp\(OB[i])) mth <- mth1 %>% str_replace_all(c("breadth" = "b", "depth" = "d", "none" = "-2", "cone" = "1", "exact" = "-2")) cat(tmp\)rowname[i],”: “, mth,” “, sep=”“) if (file_exists(paste0(iName,”“, mth1,”_result.json“))) { cat(”Already generated! “) next } # if (round(coeffRatio,3) != round(tmp\(ratioNDcoef[i], 3)) warning("Tjeck error: Ratio not the same!", coeffRatio, "!>", tmp\)ratioNDcoef) pts1 <- read_csv(grep(mth, resFilesTmp, value = T), col_types = cols()) pts2 <- full_join(pts,pts1) pts3 <- pts %>% slice(0) if (nrow(pts) != nrow(pts2) & tmp\(solved[i] == 1) warning("Tjeck error: ND sets not equal!") if (nrow(pts) == nrow(pts2)) pts3 <- pts if (tmp\)solved[i] == 0) { pts3 <- pts1[,1:tmp$p[i]] pts3 <- addNDSet(pts3) %>% select(-(nd:us), type =”cls“) } if (nrow(pts3) != tmp$YN[i]) warning(”Tjeck error: Different number of nondominated points!")

     misc <- list(
        algConfig = tmp %>% select(nodesel:OB) %>% slice(i) %>% as.list(),
        inputStat = list(
           n = tmp$n[i], coeffNDRatio = tmp$ratioNDcoef[i], coeffGenMethod = tmp$coef[i],
           coeffRange = c(tmp$rangemin[i], tmp$rangemax[i])),
        outputStat = tmp %>% select(nbnodes:maxnbpbOB) %>% slice(i) %>% as.list())
     if (tmp$solved[i] == 1) misc$xE = read_csv(grep(str_c(iName,"_XE"), resFiles, value = T), col_types = cols())
     misc$outputStat$yNStat <- pts1
     try(createResultFile(
        instanceName = iName,
        other = mth1,
        contributionName = "Forget20",
        objectives = dat$p[i],
        objectiveType = rep("int", dat$p[i]),
        direction = rep("min", dat$p[i]),
        cpu = c(sec = tmp$tpstotal[i], machineSpec = "Intel i7-4785T 2.20 GHz, 15.6 GB RAM, Ubuntu 14.04 LTS 64 bit"),
        points = pts3,
        card = tmp$YN[i],
        suppCard = nrow(dplyr::filter(pts3, type == "se" | type == "sne")),
        extCard = nrow(dplyr::filter(pts3, type == "us")),
        comments = paste0("Instance solved using config ", mth1),
        optimal = if_else(tmp$solved[i] == 1, TRUE, FALSE),
        # we add all other things under misc
        misc = misc
     ))
     #' Move the file
     jsonF <- grep("json", dir_ls(), value = T)
     file_move(jsonF, paste0("../",jsonF))
  }

} else warning(“Tjeck error: Can’t find result files!”) cat(“”) } For how to compiling reports from R script see https://rmarkdown.rstudio.com/articles_report_from_r_script.html